package transforms;

import java.util.List;

import org.objectweb.asm.tree.MethodNode;

import com.rshacking.rhf.files.ClassContainer;
import com.rshacking.rhf.updater.Transform;
import com.rshacking.rhf.updater.hooks.ClassHook;
import com.rshacking.rhf.updater.hooks.HooksList;

public class KeyboardTransforms extends Transform {

    @Override
    public boolean canActivate(final HooksList arg0, final ClassContainer arg1) {
        final List<String> list = arg1.getASM().interfaces;
        return (list.contains("java/awt/event/KeyListener") && list.contains("java/awt/event/FocusListener"));
    }

    @Override
    public boolean execute(final HooksList hooks, final ClassContainer cc) {
        if (!hooks.contains("Keyboard")) {
            hooks.add("Keyboard", cc.getName());
            hooks.add("KeyboardInput", cc.getSuperName());
        }
        
        
        /*
         * ~ _mouseExited --> hea.mouseExited
~ _mouseEntered --> hea.mouseEntered
~ _mouseClicked --> hea.mouseClicked
~ _mouseReleased --> hea.mouseReleased
~ _mouseDragged --> hea.mouseDragged
~ _mouseMoved --> hea.mouseMoved
~ _mousePressed --> hea.mousePressed
         */
        
        /*
        for (final MethodNode mn : cc.getASM().methods) {
            final String name = mn.name;
            if (name.equals("keyTyped") || name.equals("keyPressed") ||
                    name.equals("keyReleased") || name.equals("focusGained") ||
                    name.equals("focusLost")) {
                hook.addMethod("_" + name, mn);
            }
        }
        */
        return false;
    }

}
